package ca.etsmtl.logti.log619.lab05.utilities;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class ContentReader {
	public static String getContent(String filename)
	{
	    FileInputStream fis;
		try {
			fis = new FileInputStream(filename);
		
	    FileChannel fc = fis.getChannel();

	    // Read the contents of a file into a ByteBuffer
	    ByteBuffer bb = ByteBuffer.allocate((int)fc.size());
	    fc.read(bb);
	    fc.close();

	    // Convert ByteBuffer to one long String
	    return new String(bb.array());
	    
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "";
	}
	public static boolean isNum(String s) {
		try {
		Double.parseDouble(s);
		}
		catch (NumberFormatException nfe) {
		return false;
		}
		return true;
		}

}
